#ifndef BTREE_H
#define BTREE_H

#ifndef NULL
#define NULL 0
#endif

template<typename T>
class BTree {
    protected:
	class Node{
		protected:
		    Node *left;
		    Node *right;
		    T elt;
		public : 	
		    Node(T e, Node *l = NULL, Node *r = NULL)
		         : elt(e), left(l), right(r) {}
                    virtual ~Node() {  }
                    
		    inline bool isLeaf () { return (left || right) ; }
		    inline T& Root () { return elt; }
		    inline Node* Left() { return left; }
		    inline Node* Right() { return right; }
		    
        };
    public:
	BTree () { root = NULL; m_height = 0; }
        BTree (const T& e) {
            root = new Node(e);
            m_height = 1;
        }
        virtual ~BTree() {
            if(root)
                delete root;
        }
        
        bool empty() { return (root); }
        unsigned long height() { return m_height; }

    protected:
	Node *root;
        unsigned long m_height;
	
};

#endif /* BTREE_H */
